var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("NotifyEventType"),
    a = e("GlobalParams"),
    i = e("AudioManager"),
    r = e("ModuleUI"),
    s = e("CommonHelper"),
    l = e("UIManager"),
    c = e("AD"),
    d = e("Toast"),
    h = cc._decorator,
    _ = h.ccclass,
    u = h.property,
    p = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.free_btn = null),
                (t.video_btn = null),
                (t.not_popup_node = null),
                (t.lucky_box_node = null),
                (t.get_last_award_node = null),
                (t.now_lucky_num = null),
                (t.award_num = 0),
                (t.light_num = 0),
                (t.lucky_box_info = null),
                (t.light_begin = !1),
                (t.box_info = [
                    {type: 1, num: 10, name: "钻石"},
                    {type: 0, num: 300, name: "金币"},
                    {type: 3, num: 3, name: "复活币"},
                    {type: 4, num: 1, name: "英雄体验卡"},
                    {type: 1, num: 30, name: "钻石"},
                    {type: 2, num: 5, name: "随机碎片"},
                    {type: 0, num: 100, name: "金币"},
                    {type: 5, num: 1, name: "英雄"}
                ]),
                t
            );
        }
        return (
            __extends(t, e),

            (t.prototype.onDisable = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();

            }),
                        

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd(),
                Adv_skd.default.instance.hideGridAdLeft(),
                Adv_skd.default.instance.hideGridAdRight(),
                Adv_skd.default.instance.hideGridAdTop(),
                Adv_skd.default.instance.hideGridAdLeftOne(),
                Adv_skd.default.instance.hideGridAdRightOne(),
                Adv_skd.default.instance.hideGridAdButtom(),
                Adv_skd.default.instance.showGridAdTop(),
                Adv_skd.default.instance.showGridAdLeft(),
                Adv_skd.default.instance.showGridAdRight(),

                e.prototype.initView.call(this),
                    (this.lucky_box_info = a.GlobalParams.LuckyBoxInfo.value),
                    (this.get_last_award_node.active = !this.lucky_box_info.last_award),
                    (this.not_popup_node.active = this.lucky_box_info.open_today == new Date().toLocaleDateString()),
                    (this.free_btn.active = this.lucky_box_info.get_day != new Date().toLocaleDateString()),
                    (this.video_btn.active = !this.free_btn.active),
                    (this.now_lucky_num.string = "" + this.lucky_box_info.gift_num);
            }),
            (t.prototype.OnClick = function (t) {
                var o = this;
                if ((e.prototype.OnClick.call(this, t), !this.light_begin))
                    switch (t.node.name) {
                        case "back_btn":
                            a.GlobalParams.PlayerSigninInfo.value.signin_date != new Date().toLocaleDateString()
                                ? this.uiManager.showPopup("SigninViewUI")
                                : this.emitEvent(n.default.SEND_BOX_PORTAL_INFO, !0),
                                this.node.destroy();
                            break;
                        case "free_btn":
                            this.showLuckyLight();
                            break;
                        case "video_btn":
                            c.default.getInstance().showVideo(function (e) {
                                i.default.playGameBGM(), e == c.ResultEnum.Success && o.showLuckyLight();
                            });
                            break;
                        case "not_popup":
                            (this.not_popup_node.active = !this.not_popup_node.active),
                                this.not_popup_node.active
                                    ? (this.lucky_box_info.open_today = new Date().toLocaleDateString())
                                    : (this.lucky_box_info.open_today = 0),
                                (a.GlobalParams.LuckyBoxInfo.value = this.lucky_box_info);
                    }
            }),
            (t.prototype.showLuckyLight = function () {
                this.light_begin = !0;
                for (var e = 0, t = this.lucky_box_node.children; e < t.length; e++)
                    t[e].getChildByName("light").active = !1;
                this.lucky_box_info.gift_num < 7
                    ? (this.award_num = s.default.getRandomInt(40, 46))
                    : 7 == this.lucky_box_info.gift_num
                    ? (this.award_num = 47)
                    : (this.award_num = s.default.getRandomInt(40, 47)),
                    (this.light_num = 0),
                    this.showLuckyAnime(0.4);
            }),
            (t.prototype.showLuckyAnime = function (e) {
                var t = this,
                    o = this.light_num % 8;
                this.light_num > 0 &&
                    (this.lucky_box_node.children[0 == o ? 7 : o - 1].getChildByName("light").active = !1),
                    (this.lucky_box_node.children[o].getChildByName("light").active = !0),
                    i.default.getInstance().playFx("ding"),
                    this.light_num != this.award_num
                        ? this.scheduleOnce(function () {
                              t.light_num++,
                                  e > 0.15 && (e -= 0.05),
                                  t.light_num > 35 && (e += 0.05),
                                  t.showLuckyAnime(e);
                          }, e)
                        : this.scheduleOnce(function () {
                              var e = t.box_info[o],
                                  i = !0,
                                  r = !0;
                              if (e.type < 2) t.uiManager.addCoinAni(e.num, e.type), (r = !1);
                              else if (2 == e.type) {
                                  var c = s.default.getRandomInt(0, 4),
                                      h = a.GlobalParams.PlayerDowerInfo.value;
                                  (h.debris[c] += e.num), (a.GlobalParams.PlayerDowerInfo.value = h);
                              } else if (3 == e.type) {
                                  var _ = a.GlobalParams.PlayerInfo.value,
                                      u = Number(_.revive);
                                  (u += e.num),
                                      (_.revive = u),
                                      (a.GlobalParams.PlayerInfo.value = _),
                                      t.emitEvent(n.default.UPDATE_HAVE_REVIVE_NUMBER);
                              } else if (4 == e.type) {
                                  var p = a.GlobalParams.playerSkinInfo.value;
                                  p.have.taste_card++,
                                      (a.GlobalParams.playerSkinInfo.value = p),
                                      t.emitEvent(n.default.UPDATE_HAVE_TASTE_CARD_NUMBER);
                              } else if (5 == e.type)
                                  if (t.lucky_box_info.last_award) {
                                      t.lucky_box_info.last_award = !1;
                                      var m = a.GlobalParams.playerSkinInfo.value;
                                      (m.use[0] = 11),
                                          m.have.hero.push(11),
                                          (a.GlobalParams.playerSkinInfo.value = m),
                                          cc.find("UIManager").getComponent(l.default).showPopup("ObtainHeroTipView");
                                  } else (i = !1), t.uiManager.addCoinAni(30, 2);
                              t.lucky_box_info.gift_num++,
                                  (t.lucky_box_info.get_day = new Date().toLocaleDateString()),
                                  (a.GlobalParams.LuckyBoxInfo.value = t.lucky_box_info),
                                  (t.now_lucky_num.string = "" + t.lucky_box_info.gift_num),
                                  t.emitEvent(n.default.SEND_COCOS_ANALYTICS, {
                                      name: "事件一",
                                      info: "抽奖次数：" + t.lucky_box_info.gift_num
                                  }),
                                  r &&
                                      (i
                                          ? d.default.showNewToast(
                                                "恭喜获得" + t.box_info[o].name + " * " + t.box_info[o].num
                                            )
                                          : d.default.showNewToast("恭喜获得钻石 * 30")),
                                  cc.find("UIManager").getComponent(l.default).playerTaskOverInfo(2, 1),
                                  (t.free_btn.active = t.lucky_box_info.get_day != new Date().toLocaleDateString()),
                                  (t.video_btn.active = !t.free_btn.active),
                                  (t.light_begin = !1);
                          }, 1);
            }),
            __decorate([u(cc.Node)], t.prototype, "free_btn", void 0),
            __decorate([u(cc.Node)], t.prototype, "video_btn", void 0),
            __decorate([u(cc.Node)], t.prototype, "not_popup_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "lucky_box_node", void 0),
            __decorate([u(cc.Node)], t.prototype, "get_last_award_node", void 0),
            __decorate([u(cc.Label)], t.prototype, "now_lucky_num", void 0),
            __decorate([_], t)
        );
    })(r.default);
o.default = p;
